﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace asp.netWebFroms
{
    public class DbHelper
    {
        private readonly static string conString="server=.;uid=sa;pwd=123456;database=CMS";

        public static DataTable Table(string sql)        
        {
            SqlDataAdapter adapter = new SqlDataAdapter(sql,conString);
            DataTable table = new DataTable();
            adapter.Fill(table);
            return table;
        }

        public static int AddOrUpdateDelete(string sql)

        {
            using (SqlConnection con=new SqlConnection(conString)) 
            {
                con.Open();
                SqlCommand cmd = new SqlCommand(sql,con);
                var num = cmd.ExecuteNonQuery();
                return num;
            }
        }
    }
}